from app.common.Remote import *

class Products(Remote):
    api = 'search/search_box/products'
    def __init__(self, product_id=None):
        self.product_id = product_id

    def getSearchProducts(self, search_term):
        self.params = {'page': 1, 'search_term': search_term, 'search_term_from': 20, 'size': 20, 'sort': 0,
                  'store_id': 'a3f5582f-7c6f-4c42-8736-72c8f9620656'}
        self.get()
        result = self.resolve()
        if (result['data']['products'][0]['id']):
            self.setProductId(result['data']['products'][0]['id'])
        return result

    def setProductId(self, productId):
        self.product_id = productId

    def getProductId(self):
        return self.product_id